import pandas as pd
import statsmodels.api as sm
import matplotlib.pyplot as plt

num_days = 38
num_spec_days = 2  # should be greater than 1
coef_nangzhong = 2
datas = pd.read_excel(r'F:\Program Files\Projects\data\doudou\doudou.xlsx',
                      engine='openpyxl', nrows=num_days)

print("\n\nPredicting using all columns:")
y0 = datas.iloc[:, 2] + coef_nangzhong * datas.iloc[:, 3]
y = pd.Series(y0.iloc[:-(num_spec_days-1)].to_numpy() + y0.iloc[num_spec_days-1:].to_numpy())
x = datas.iloc[:-(num_spec_days-1), 4:]
x = sm.add_constant(x)
model = sm.OLS(y, x).fit()
print(model.summary())

print("\n\nPredicting using only selected columns:")
selected_col_names = ['使用维A酸', '温差(℃)', '含糖饮料糖量(g)', '压力评级']
x = pd.DataFrame(data=x, columns=selected_col_names)
x = sm.add_constant(x)
model = sm.OLS(y, x).fit()
print(model.summary())
